package cn.net.xyan.easy.webapp.base.entity;

import javax.persistence.*;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by xiashenpin on 16/2/9.
 */
@Entity
@Table(name = "module")
public class WebModule {
    String name;
    String title;
    String url;
    Integer orderIndex;
    List<Permission> requiredPermission = new LinkedList<>();
    List<WebModule> items = new LinkedList<>();
    WebModule parent;

    @Id
    @Column(name = "name",length = 1024)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @OneToMany
    @JoinTable(name = "t_sys_module_permission_join")
    public List<Permission> getRequiredPermission() {
        return requiredPermission;
    }

    public void setRequiredPermission(List<Permission> requiredPermission) {
        this.requiredPermission = requiredPermission;
    }

    @OneToMany(mappedBy = "parent")
    @OrderBy("orderIndex ASC")
    public List<WebModule> getItems() {
        return items;
    }

    public void setItems(List<WebModule> items) {
        this.items = items;
    }

    @ManyToOne
    @JoinColumn(name = "parent")
    public WebModule getParent() {
        return parent;
    }

    public void setParent(WebModule parent) {
        this.parent = parent;
    }

    public Integer getOrderIndex() {
        return orderIndex;
    }

    public void setOrderIndex(Integer orderIndex) {
        this.orderIndex = orderIndex;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
